package service.Impl;

import dao.CustomerRepository;
import dao.Impl.CustomerRepositoryImpl;
import entity.Customer;
import service.CustomerService;

import java.util.ArrayList;

public class CustomerServiceImpl implements CustomerService {

    /**
     * 获取客户信息表
     */
    @Override
    public ArrayList<Customer> getCustomerList(){
        CustomerRepository customerRepository = new CustomerRepositoryImpl();
        return customerRepository.getCustomerList();
    }

    /**
     * 添加客户信息
     */
    @Override
    public boolean addCustomer(Customer customer) {
        CustomerRepository customerRepository = new CustomerRepositoryImpl();
        return customerRepository.addCustomer(customer);
    }

    /**
     * 根据客户编号返回客户信息
     */
    @Override
    public Customer findById(Integer customerId) {
        CustomerRepository customerRepository = new CustomerRepositoryImpl();
        return customerRepository.findById(customerId);
    }
    /**
     * 修改客户信息
     */
    @Override
    public boolean updateCustomer(Customer customer) {
        CustomerRepositoryImpl customerRepository = new CustomerRepositoryImpl();
        return customerRepository.updateCustomer(customer);
    }

    /**
     * 根据客户编号删除客户信息
     */
    @Override
    public boolean deleteCustomer(Integer customerId) {
        CustomerRepository customerRepository = new CustomerRepositoryImpl();
        return customerRepository.deleteCustomer(customerId);
    }

}
